/////////////////////////////////page_carRentalOrderGetCar//////////////////////////////
$(document).on("pageInit", "#page_carRentalOrderGetCar", function(e, pageId, $page) {
    my.givetitle('车辆出租');
	                 $.showPreloader()
      			    key=my.get_key(my.getCookie('token'))
					//获取信息开始
					var info_yc={
      					order_id:sessionStorage.cartime_id,
      					type:sessionStorage.yctypeCarRental
      			    }
      				info_yc=my.cryptoASEencrypt(JSON.stringify(info_yc),key)
      				$.ajax({
      					url:api.viewcheckcar,
      					type: 'post',
      					async:true,
      					data:{
      						'api_value':info_yc
      					},
      					error:function(){
      							$.toast("获取失败，请点击重新获取");
      						},
      					success:function(data){
      						$.hidePreloader()
      						if(data.match("err_code")!=null){
      							switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									   my.tokenExpire()
      									   break;
      									default:
      									   $.toast(JSON.parse(data).err_msg);
      								}
      							}else{
      								 data=JSON.parse(data)
      								 data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
      							     console.log(data)
      							     if(data.info[0].sure_state==1){
      							     	$('.CCD-btn').hide()
      							     }
      							     workorder_id=data.info[0].workorder_id
      							     workstep_id=data.info[0].workstep_id
      							     $('.CCD-dl span').eq(-1).text(data.info[0].manage_fullname)
      							     $('.hc-yb').text(data.info[0].fuel_meter)
      							     $('.qc-yb').text(data.info[0].fuelmeter_get)
      							     $('.cha-yb').text(data.info[0].fuelmeter_diff)
      							     $('.hc-gl').text(data.info[0].mileage_data+'公里')
      							     $('.qc-gl').text(data.info[0].mileagedata_get+'公里')
      							     $('.cha-gl').text(data.info[0].mileagedata_diff+'公里')
      							     for(var i=0;i<data.img.length;i++){
      							     	switch(+data.img[i].checkcarimg_type)
      								    {
      									case 1:
      									   $('.swiper-a').append('<div class="swiper-slide"><img src="'+config.url+data.img[i].checkcar_img +'"></div>')
      									   if(data.img[i].check_remarks!='')
      									    {$('.bz-a-ycd').text(data.img[i].check_remarks)}
      									   break;
      									case 3:
      									   $('.swiper-a').append('<div class="swiper-slide"><img src="'+config.url+data.img[i].checkcar_img +'"></div>')
      									   if(data.img[i].check_remarks!='')
      									    {$('.bz-a-lcyb').text(data.img[i].check_remarks)}
      									   break;
      									case 4:
      									   $('.swiper-a').append('<div class="swiper-slide"><img src="'+config.url+data.img[i].checkcar_img +'"></div>')
      									   if(data.img[i].check_remarks!='')
      									    {$('.bz-a-lcyb').text(data.img[i].check_remarks)}
      									   break;
      									case 2:
      									   $('.swiper-b').append('<div class="swiper-slide"><img src="'+config.url+data.img[i].checkcar_img +'"></div>')
      									   if(data.img[i].check_remarks!='')
      									    {$('.bz-b').text(data.img[i].check_remarks)}
      									   break;
//    									case 5:
//    									   $('.swiper-c').append('<div class="swiper-slide"><img src="'+config.url+data.img[i].checkcar_img +'"></div>')
//    									   if(data.img[i].check_remarks!='')
//    									    {$('.bz-c').text(data.img[i].check_remarks)}
//    									   break;
      								    }
      							     }
      							     for(var i=0;i<data.damage.length;i++){
      							     	var list='<div class="table-head-a" style="border-top: solid thin #ccc;margin-top: 1rem;"><span>车损项目</span><span>'+data.damage[i].damage_item+'</span></div>'
      							     	         +'<div class="table-head-a"><span>车损状况</span><span>'+data.damage[i].status_dec+'</span></div>'
      							                 +'<div class="table-head-a"><span>预估维修费</span><span>'+data.damage[i].damage_cost+'</span></div>'
      							                 +'<div class="table-head-a"><span>登记时间</span><span>'+data.damage[i].damage_time+'</span></div>'
      							                 +'<div class="table-head-a"><span>车损部位</span><span>'+data.damage[i].option_dec+'</span></div>'
      							                 +'<div class="table-head-a"><span>处理意见</span><span>'+data.damage[i].damage_deal+'</span></div>'
      							                 +'<div class="table-head-a"><span>车损确认费用</span><span>'+data.damage[i].cost+'</span></div>'
      							               $('.qc_damage_list').append(list)
      							     }
      							     var mySwiper = new Swiper('.CD-swiper',{
                                        pagination : '.swiper-pagination',
                                       })
      							}
      					}
      				})
					//获取信息结束
					//确认验车开始
					$('.CCD-btn').click(function(){
						$.showPreloader()
						var info_ycok={
      					workorder_id:workorder_id,
      					workstep_id:workstep_id,
      					manage_id:my.getCookie('id')
      			        }
      				   info_ycok=my.cryptoASEencrypt(JSON.stringify(info_ycok),key)
      				$.ajax({
      					url:api.stepscomplete,
      					type: 'post',
      					async:true,
      					data:{
      						'api_value':info_ycok
      					},
      					error:function(){
      						    $.hidePreloader()
      							$.toast("提交失败，请重新提交");
      						},
      					success:function(data){
      						$.hidePreloader()
      						if(data.match("err_code")!=null){
      							switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									   my.tokenExpire()
      									   break;
      									default:
      									   $.toast(JSON.parse(data).err_msg);
      								}
      							}else{
      						$.alert('验车成功',function(){
      						//	$.router.loadPage("carRentalOrderDetails.html");
                                $.router.load(carRentalOrderDetailsUrl,true);
      						})
      						}

      					}
					    })
      		        })
					//确认验车结束
})